package com.miniserver.filter;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.annotation.WebFilter;

import com.miniserver.util.LogUtil;

/**
 * 捕获其他未处理错误
 * tomcat对于声明的Filter处理顺序是按照字母顺序执行的
 * @author zzlt104
 *
 */
@WebFilter(filterName="a1ExceptionHandlerFilter", urlPatterns="/*")
public class ExceptionHandlerFilter implements Filter {
	LogUtil log =LogUtil.getLogUtil("ExceptionHandlerFilter");
	/**
	 * 销毁
	 */
	public void destroy() {
	}
/**
 * 记录未处理的错误
 */
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		try {
			chain.doFilter(request, response);
		} catch (Exception e) {
			log.error("错误:", e);
		}
	}
/**
 * 初始化
 */
	public void init(FilterConfig arg0) throws ServletException {
	}
}
